package com.service.utills;

import android.util.Log;

import com.service.entities.Login;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by rora0613 on 30.09.13.
 */
public class JSONConverter {
    //TODO:setJsonPhone is just for training. Will be removed later
    public JSONObject setJsonPhone(String phone) {

        JSONObject jsData = new JSONObject();
        try {

            jsData.put("phone", phone);
            Log.e("Json Data", "Json Data For Home is  : " + jsData.toString());

        } catch (JSONException e) {
            Log.e("Error: ", "occurs during trying to create JSON Phone object.");
            e.printStackTrace();
        }
        return jsData;
    }

    public JSONObject setJsonLogin(Login login) {

        JSONObject jsData = new JSONObject();
        try {

            jsData.put("login", login.getLogin());
            jsData.put("password", login.getPassword());
            Log.e("Json Data", "Json Data For Login is  : " + jsData.toString());

        } catch (JSONException e) {
            Log.e("Error: ", "occurs during trying to create JSON Login object.");
            e.printStackTrace();
        }
        return jsData;
    }

    public JSONObject setJsonCustomer(String firstName, String lastName, String phoneNo) {

        JSONObject jsData = new JSONObject();
        try {

            jsData.put("firstName", firstName);
            jsData.put("lastName", lastName);
            jsData.put("phoneNumber", phoneNo);
            Log.e("Json Data", "Json Data For Customer is  : " + jsData.toString());

        } catch (JSONException e) {
            Log.e("Error: ", "occurs during trying to create JSON Customer object.");
            e.printStackTrace();
        }
        return jsData;
    }

    public JSONObject setJsonPizza(String size, int chicken, int mushroms, int chesse) {

        JSONObject jsData = new JSONObject();
        try {

            jsData.put("size", size);
            jsData.put("chicken", chicken);
            jsData.put("mushroms", mushroms);
            jsData.put("cheese", chesse);
            Log.e("Json Data", "Json Data For Pizza is  : " + jsData.toString());

        } catch (JSONException e) {
            Log.e("Error: ", "occurs during trying to create JSON Pizza object.");
            e.printStackTrace();
        }
        return jsData;
    }
}
